package com.cn.demo4.service.impl;

import com.cn.demo4.dao.NavDao;
import com.cn.demo4.dao.impl.NavDaoImpl;
import com.cn.demo4.model.NavModel;
import com.cn.demo4.service.INavService;

import java.util.List;

public class NavServiceImpl implements INavService {
    @Override
    public List<NavModel> findAll(NavModel navModel) {
        NavDao navDao = new NavDaoImpl();
        return navDao.findAll(navModel);
    }

    @Override
    public String add(NavModel navModel) {
        NavDao navDao = new NavDaoImpl();
        return navDao.add(navModel) == 1 ? "success" : "error";
    }

    @Override
    public NavModel findById(Integer id) {
        NavDao navDao = new NavDaoImpl();
        return navDao.findById(id);
    }

    @Override
    public String update(NavModel navModel) {
        NavDao navDao = new NavDaoImpl();
        return navDao.update(navModel) == 1 ? "success" : "error";
    }

    @Override
    public int del(Integer id) {
        NavDao navDao = new NavDaoImpl();
        return navDao.del(id);
    }

    @Override
    public List<NavModel> getNavModelListForHome() {
        NavDao navDao = new NavDaoImpl();
        return navDao.getNavModelListForHome();
    }

    @Override
    public int getCount(NavModel navModel) {
        NavDao navDao = new NavDaoImpl();
        return navDao.getCount(navModel);
    }
}
